#ifndef DEVICECONTROLLERUI_H
#define DEVICECONTROLLERUI_H

#include <QQmlEngine>
#include "serialport_engine.h"

class DeviceControllerUI : public QObject {
    Q_OBJECT
    QML_ELEMENT
public:
    DeviceControllerUI();

signals:
    // 信号，向View层传递
    void deviceRxIndication(const QString &msg);
    void deviceStatusChanged(bool isConnected);
    void deviceListChanged(const QStringList &list);

public slots:
    // 槽函数，响应View层信号
    void updateDeviceList();
    void updateSettings(int parameter1, int parameter2, int parameter3, int parameter4);
    void connectDevice(const QString &name);
    void disConnectDevice();
    void sendMessage(const QString &message);

    // 槽函数，处理SerialPortEngine的接收数据流
    void handleSerialPortRxIndication(const PduInfoType *pdu);

private:
    SerialPortEngine* serial = nullptr;
};

#endif // DEVICECONTROLLERUI_H
